<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="../common/taglib.jsp" %>
<script type="text/javascript" src="<c:url value="/js/ajaxfileupload.js"/>"></script>
		<div class="resume-title">         
         	基本资料
        </div>
        <div class="resume-user-info" id="resumeinfo">
        <div id="NTGUID__2" data-selecter="show_user_info" data-completed="completed">
		<div id="NTGUID__2NDTGUID__v">
		  <div class="resume-complete">		  
		    <table class="resume-table">	    
		      <tbody>	      
		     	    <tr>
		              <th>出生年份：</th>
		              <td>${resume.userInfo.birth }</td>
		              <th>工作经验：</th>
		              <td>${resume.userInfo.experience }</td>
		            </tr>		        
		            <tr>
		              <th>手机：</th>
		              <td>${resume.userInfo.phone }</td>
		              <th>邮箱：</th>
		              <td>${resume.userInfo.mailbox }</td>
		            </tr>		        
		            <tr>
		              <th>证件类型：</th>
		              <td>${resume.userInfo.paperType }</td>
		              <th>证件号：</th>
		              <td>${resume.userInfo.paperId }</td>
		            </tr>	
		            <tr>
		              <th>居住地：</th>
		              <td>${resume.userInfo.livePlace }</td>
		            </tr>		        
		      </tbody>		       
		    </table>
		    <div class="edit-btns" >
		    	<img alt="" src="../images/edit_btn.jpg" onclick="show('cardinfo','resumeinfo')" style="cursor: hand">	    
		    </div>
		  </div>
		</div>
	 </div>
	</div>

	<script type="text/javascript" >		
		function updateUser(form){
			var name = form.name.value;
			var mailbox = form.mailbox.value;
			var phone = form.phone.value;
			var id = '${user.id}';
			var password = '${user.password}';
			var data = '{"name":"'+name+'","mailbox":"'+mailbox+'","phone":"'+phone+'","id":"'+id+'","password":"'+password+'"}';
//alert(data);
			$.ajax({
				url:'<c:url value="user/updateByInfo"/>',
				type:'POST',
				contentType : 'application/json', 
				cache:false,
				dataType:'json',
				data:data,
				success:function(){	
//alert("chenggong ");
					hide('cardinfo','resumeinfo');
				}
			}); 
			
		}
	</script>
		
	<div class="card-info" id="cardinfo" style="display:none">
      <div id="NTGUID__8" data-selecter="show_card_info" >
		<div class="card-edit-main clearfix" id="NTGUID__8NDTGUID__o">
				    		      
		    <div class="card-edit-content resume-edit" style="width:50%">
		      <div id="faceBox" class="card-edit-avatar" style="width:15%" >
			      <p class="edit-avatar-img"><img class="middleFace" src="${resume.userInfo.photopath }" id="image"></p>
			      	<input type="file" id="photo" name="photo" onchange="change(this)">
			      	<input type="submit" value="上传" onclick="uploadFile(${resume.userInfo.id})">			      	
			      	<span style="color:red" id="msg"></span>
		      </div>
		    
		      <form:form action="saveinfo" modelAttribute="userInfoModel" method="post" onsubmit="updateUser(this)" >
		       <%-- <form:form onsubmit="saveInfo(this)" > --%>
		      <input type="hidden" name="id" value="${resume.userInfo.id}">
			  <input type="hidden" name="resumeId" value="${resume.id} ">     
		        <table>
		          <tbody>
		            <tr>
		              <th class="th-name">姓名</th>
		              <td colspan="3" class="clearfix">		                
		                <input type="text" maxlength="5" name="name" class="text mr10 float-left"  value="${resume.userInfo.name }">		                 		           
		              </td>
		            </tr>
		            <tr>
		              <th>性别</th>
		              <td colspan="3">
		              <c:if test="${resume.userInfo.sex==null }">
		                <label><input type="radio" checked="checked" class="radio" name="sex" value="男" >男</label>&nbsp;
		                <label><input type="radio" class="radio" name="sex" value="女" >女</label>  
		              </c:if>
		              <c:if test="${resume.userInfo.sex=='男' }">
		                <label><input type="radio" checked="checked" class="radio" name="sex" value="男" >男</label>&nbsp;
		                <label><input type="radio" class="radio" name="sex" value="女" >女</label>  
		              </c:if>
		               <c:if test="${resume.userInfo.sex=='女' }">
		                <label><input type="radio"  class="radio" name="sex" value="男" >男</label>&nbsp;
		                <label><input type="radio" checked="checked" class="radio" name="sex" value="女" >女</label>  
		              </c:if>
		              </td>		              
		            </tr>
		            <tr>
		              <th><p class="w88">出生年份</p></th>
		              <td>
		                <input type="datetime" class="text" name="birth" value="${resume.userInfo.birth }" >
		              </td>
		              <th class="short"><p class="w68">工作经验</p></th>
		              <td>
		                <input type="text" class="text" name="experience" value="${resume.userInfo.experience}" >
		              </td>
		            </tr>
		            <tr>
		              <th><p class="w88">邮箱</p></th>
		              <td>
		                <input type="email" class="text" name="mailbox" value="${resume.userInfo.mailbox }" >
		              </td>
		              <th class="short"><p class="w68">电话</p></th>
		              <td>
		                <input type="text" class="text" name="phone" value="${resume.userInfo.phone}" >
		              </td>
		            </tr>
		            <tr>
		              <th><p class="w88">证件类型</p></th>
		              <td>
		                <input type="text" class="text" name="paperType" value="${resume.userInfo.paperType}" >
		              </td>
		              <th class="short"><p class="w68">证件号</p></th>
		              <td>
		                <input type="text" class="text" name="paperId" value="${resume.userInfo.paperId }" >
		              </td>
		            </tr>       
		            <tr>
		              <th>常住地区</th>
		              <td colspan="3" class="setjobw">
		                <input type="text" class="text span13" name="livePlace" value="${resume.userInfo.livePlace}">
		              </td>
		            </tr>
		            <tr>
		              <th>&nbsp;</th>
		              <td colspan="3" class="btns">
		                <input type="submit" class="btn btn-primary" id="infobtn" value="保 存">
		                <a href="javascript::;" onclick="hide('cardinfo','resumeinfo')">取消</a>
		              </td>
		             </tr>
		           </tbody>
		          </table>
		          <div style="color:red"><form:errors path="*"></form:errors></div>
		         </form:form>
		     </div>
		  </div>	
	  </div>
	</div>
	
	<script type="text/javascript">
		function uploadFile(userInfoId){ 
			   $("#loading")
		     .ajaxStart(function(){
		         $(this).show();
		     })
		     .ajaxComplete(function(){
		         $(this).hide();
		     });
			if(userInfoId!=null){
				 $.ajaxFileUpload({  
				         url:"http://localhost:8080/ersup/upload?userInfoId="+userInfoId+"&method=userInfo",            //需要链接到服务器地址  
				         secureuri:false,  
				         fileElementId:'photo',                        //文件选择框的id属性  
				         dataType:'json',
				         success: function(data, status){     
				             document.getElementById("msg").innerHTML=data.result;
				         }  
				     });  
			} else{
				document.getElementById("msg").innerHTML="需要先填写人员信息";
			}
		} 
		function change(input){
			var objectURL = getObjectURL(input.files[0]);
			if(objectURL){
				$('#image').attr('src',objectURL);
				$('#img').attr('src',objectURL);
			}
		}
		function getObjectURL(file){
			var url = null;
			if(window.createObjectURL != undefined){
				url = window.createObjectURL(file);
			} else if(window.URL != undefined){
				url = window.URL.createObjectURL(file);
			} else if(window.webkitURL != undefined){
				url = window.webkitURL.createObjectURL(file);
			}
			return url;
		}
	</script>